/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package connectDB;

import java.sql.*;

public class ConnectDB {

    public Connection cn;

    public void getConnect() {
        try {

            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String url = "jdbc:sqlserver://localhost:1433;DatabaseName=IMPRO";
            cn = DriverManager.getConnection(url, "sa", "");

            if (cn != null) {
                System.out.println("Connect to database successfully!");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static void main(String[] args) {
        ConnectDB c = new ConnectDB();
        c.getConnect();

    }
}